package ioHelper;


import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;



public class IOHelper {
	@SuppressWarnings("unchecked")
	//lyh
	public ArrayList<Object> getInfo(String filename) {

		ArrayList<Object> list = new ArrayList<Object>();

		try {
			ObjectInputStream in = new ObjectInputStream(new FileInputStream(
					filename + ".dat"));
			list = (ArrayList<Object>) in.readObject();
			in.close();
			return list;
		} catch (ClassNotFoundException | IOException e) {
			
		}

		return list;
	}

	//lyh
	public String writeFile(ArrayList<Object> a, String filename) {

		try {
			ObjectOutputStream out = new ObjectOutputStream(
					new FileOutputStream(filename + ".dat"));
			out.writeObject(a);
			out.close();
			return "success";

		} catch (IOException e) {
			e.printStackTrace();
		}
		return "fail";

	}

}
